package com.healthcloud.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.healthcloud.dao.MedicationGuidMapper;
import com.healthcloud.entity.MedicationGuid;
import com.healthcloud.entity.MedicationGuidOfMedicaName;
import com.healthcloud.service.MedicationGuidService;

/**
 * Created by XYC on 2015/9/16.
 */
@Service
@Transactional
public class MedicationGuidServiceImpl implements MedicationGuidService {

    @Autowired
    private MedicationGuidMapper medicationGuidMapper;

    @Override
    public MedicationGuid saveOrUpdata(MedicationGuid medicationGuid) {
        return null;
    }

    @Override
    public ArrayList<MedicationGuid> findByEntity(MedicationGuid medicationGuid) {
        return (ArrayList<MedicationGuid>) medicationGuidMapper.findByEntityAll(medicationGuid);
    }

    @Override
    public ArrayList<MedicationGuidOfMedicaName> findAllMedicaName() {
        return medicationGuidMapper.findByAllMedicalNameData();
    }

    @Override
    public MedicationGuid findByFid(MedicationGuid medicationGuid) {
       /* MedicationGuid medicationGuid1 = new MedicationGuid();
        medicationGuid1.setId(medicationGuid.getId());
        ArrayList<MedicationGuid> medicationGuidArrayList =findByEntity(medicationGuid1);
        if (medicationGuidArrayList.size()==0){
            return null;
        }
        medicationGuidArrayList.get(0).setUpdatedTime(null);
        medicationGuidArrayList.get(0).setCreatedTime(null);
        return medicationGuidArrayList.get(0);*/
        return medicationGuidMapper.get(medicationGuid.getId());
    }

    @Override
    public List<MedicationGuid> findByLikeMedicationName(String medicationName) {
        return medicationGuidMapper.findByLikeMedicationName(medicationName);
    }

    @Override
    public List<String> findMedicationNameByLikeMedicationName(String medicationName) {
        return medicationGuidMapper.findMedicationNameByLikeMedicationName(medicationName);
    }
}
